<?php
class Tag_Editor{
	
	public static $XSL;
}

Tag_Editor::$XSL = <<<EOD
<xsl:template name="left-trim">
  <xsl:param name="s" />
  <xsl:choose>
    <xsl:when test="substring(\$s, 1, 1) = ''">
      <xsl:value-of select="\$s"/>
    </xsl:when>
    <xsl:when test="normalize-space(substring(\$s, 1, 1)) = ''">
      <xsl:call-template name="left-trim">
        <xsl:with-param name="s" select="substring(\$s, 2)" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="\$s" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="right-trim">
  <xsl:param name="s" />
  <xsl:choose>
    <xsl:when test="substring(\$s, 1, 1) = ''">
      <xsl:value-of select="\$s"/>
    </xsl:when>
    <xsl:when test="normalize-space(substring(\$s, string-length(\$s))) = ''">
      <xsl:call-template name="right-trim">
        <xsl:with-param name="s" select="substring(\$s, 1, string-length(\$s) - 1)" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="\$s" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="trim">
  <xsl:param name="s" />
  <xsl:call-template name="right-trim">
    <xsl:with-param name="s">
      <xsl:call-template name="left-trim">
        <xsl:with-param name="s" select="\$s" />
      </xsl:call-template>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>


<xsl:template match="i:editor">
<link rel="stylesheet" href="/res/editor/css/editor.css" type="text/css" />
<script tppe="text/javascript" src='/res/editor/js/webeditor.js'></script>
<div style="display:none"><textarea id="{@div-id}textarea"><xsl:value-of select="i:content"/></textarea></div>
<div id="{@div-id}" style="display: inline-block; float: left; margin-bottom: 10px;"></div>
<div class="clearfix"></div>
<script type="text/javascript">
var e_fontsize = <xsl:choose><xsl:when test="i:toolbar/@fontsize='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_face = <xsl:choose><xsl:when test="i:toolbar/@face='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_media = <xsl:choose><xsl:when test="i:toolbar/@media='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_bold = <xsl:choose><xsl:when test="i:toolbar/@bold='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_InsertOrderedList = <xsl:choose><xsl:when test="i:toolbar/@orderedList='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_italic = <xsl:choose><xsl:when test="i:toolbar/@italic='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_underline = <xsl:choose><xsl:when test="i:toolbar/@underline='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_JustifyLeft = <xsl:choose><xsl:when test="i:toolbar/@left='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_JustifyCenter = <xsl:choose><xsl:when test="i:toolbar/@center='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_JustifyRight = <xsl:choose><xsl:when test="i:toolbar/@right='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_font = <xsl:choose><xsl:when test="i:toolbar/@font='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_color = <xsl:choose><xsl:when test="i:toolbar/@color='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_backcolor = false;
var e_img = <xsl:choose><xsl:when test="i:toolbar/@link-img='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_link = <xsl:choose><xsl:when test="i:toolbar/@link='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_uploadimg = <xsl:choose><xsl:when test="i:toolbar/@uploadimg='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_piclink = false;
var e_CommentFace = <xsl:choose><xsl:when test="i:toolbar/@commentface='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
var e_toolbarbg = <xsl:choose><xsl:when test="i:toolbar/@toolbarbg='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
<xsl:value-of select="@id"/> = new webEditor(
	"<xsl:value-of select="@id"/>" , 
	$("<xsl:value-of select="@div-id"/>") , 
	<xsl:choose><xsl:when test="i:content/@width"><xsl:value-of select="i:content/@width"/></xsl:when><xsl:otherwise>400</xsl:otherwise></xsl:choose>, 
	<xsl:choose><xsl:when test="i:content/@height"><xsl:value-of select="i:content/@height"/></xsl:when><xsl:otherwise>300</xsl:otherwise></xsl:choose>
);
<xsl:value-of select="@id"/>.init($('<xsl:value-of select="@div-id"/>textarea').value);
</script>
</xsl:template>
EOD;
